if (typeof(Edushare) == "undefined") Edushare = { };
if (typeof(Edushare.PollQuestions) == "undefined") Edushare.PollQuestions = { };

Edushare.PollQuestions.showMultipleChoice = function(node){
	Edushare.PollQuestions.hideAll();
	$(node).closest("form").find('.MCMOSODIV').show();
};

Edushare.PollQuestions.showTextInput = function(node){
	Edushare.PollQuestions.hideAll();
	$(node).closest("form").find('.FFDIV').show();
};

Edushare.PollQuestions.showRatingInput = function(node){
	Edushare.PollQuestions.hideAll();
	$(node).closest("form").find('.RATINGDIV').show();
};

Edushare.PollQuestions.hideAll = function(){
	$('.MCMOSODIV').hide();
	$('.FFDIV').hide();
	$('.RATINGDIV').hide();		
};

Edushare.PollQuestions.parentForm = function(aThis){
	return $(aThis).closest("form");
};

$(document).ready(function(){
	$('.ratingQuestionSlider').each(function(){
		var value = $(this).next().val();
		$(this).prev().children(".ratingDisplay").val(value + " of 10");
		$(this).slider({
			range: "min",
			min: 1,
			max: 10,
			value: value,
			slide: function(event, ui) {
				$(this).next().val(ui.value);
				$(this).prev().children(".ratingDisplay").val(ui.value + " of 10");
			}
		});
	});
	
	Edushare.PollQuestions.hideAll();
	
	$('.ratingAnswer').each(function(){
		$(this).slider({
			range: "min",
			min: 1,
			max: 10
		}).slider('disable').slider("value",$(this).attr('rating'));
	});
	
	$(".addQuestionMcso").each(function(){
		if($(this).is(":checked")){
			Edushare.PollQuestions.showMultipleChoice(this);
		};
	});
	
	$(".addQuestionFree").each(function(){
		if($(this).is(":checked")){
			Edushare.PollQuestions.showTextInput(this);
		};
	});
	
	$(".addQuestionDropDown").each(function(){
		if($(this).is(":checked")){
			Edushare.PollQuestions.showMultipleChoice(this);
		};
	});
	
	$(".addQuestionShortText").each(function(){
		if($(this).is(":checked")){
			Edushare.PollQuestions.showTextInput(this);
		};
	});
	
	$(".addQuestionMcmo").each(function(){
		if($(this).is(":checked")){
			Edushare.PollQuestions.showMultipleChoice(this);
		};
	});
	
	$(".addQuestionRating").each(function(){
		if($(this).is(":checked")){
			Edushare.PollQuestions.showRatingInput(this);
		};
	});
	
	$(".addQuestionPref").each(function(){
		if($(this).is(":checked")){
			Edushare.PollQuestions.showMultipleChoice(this);
		};
	});
	
	$(".addQuestionMcso").change(function(){
		Edushare.PollQuestions.showMultipleChoice(this);
	});
	
	$(".addQuestionFree").change(function(){
		Edushare.PollQuestions.showTextInput(this);
	});
	
	$(".addQuestionDropDown").change(function(){
		Edushare.PollQuestions.showMultipleChoice(this);
	});
	
	$(".addQuestionShortText").change(function(){
		Edushare.PollQuestions.showTextInput(this);
	});
	
	$(".addQuestionMcmo").change(function(){
		Edushare.PollQuestions.showMultipleChoice(this);
	});
	
	$(".addQuestionRating").change(function(){
		Edushare.PollQuestions.showRatingInput(this);
	});
	
	$(".addQuestionPref").change(function(){
		Edushare.PollQuestions.showMultipleChoice(this);
	});
	
	
	$('.newPollLastDate').datepicker().datepicker('option', {
		showAnim : 'fadeIn'
		}).datepicker('option', 'dateFormat', 'd M yy')
		.datepicker('setDate', new Date()).datepicker('setDate',new Date());
});


